package priv.mill.db;

import java.sql.SQLException;
import java.util.List;

public interface Service<T> {
	static <T> Service<T> createService(Class<T> clazz) {
		return new SimpleService<T>(clazz);
	}

	static <T> Service<T> createService(Class<T> clazz, String tableName) {
		return new SimpleService<T>(clazz, tableName);
	}

	T findById(int id) throws SQLException, Exception;

	T findOne(String sql, Object... args) throws SQLException, Exception;
	
	List<T> findByPage(Integer pageNum,Integer pageSize) throws SQLException, Exception;
	
	List<T> find(String sql, Object... args) throws SQLException, Exception;
	
	Integer insert(T obj) throws SQLException, Exception;
	
	Integer update(T obj) throws SQLException, Exception;
	
	Integer delete(int id) throws SQLException, Exception;
	
}
